package com.hexacta.hrs.test.data;

import java.util.List;
import java.util.Map;

import org.vectrics.domain.Domain;
import org.vectrics.system.SystemConstant;

import com.hexacta.hrs.Version;

/**
 * Test data dependency creator for the SystemConstant class.
 * 
 * @author tpollak
 */
public class SystemConstantTestDataDependencyCreator extends AbstractTestDataDependencyCreator {

    public SystemConstantTestDataDependencyCreator(List<TestDataDependencyCreator> dependencies) {
        super(dependencies);
    }

    public void createDependentTestData(Map<String, Object> context) {
        // Create the system constants
        this.createAndInsertSystemConstant(context, "domain.single", "false", "boolean",
                "Does system have single domain", true, false);
        this.createAndInsertSystemConstant(context, "system.domain.id", "1", "long", "System domain", false, true);
        this.createAndInsertSystemConstant(context, "demo", "false", "boolean",
                "Demonstration - is this a demonstration version", false, true);
        this.createAndInsertSystemConstant(context, "phone.number.reqexp",
                "([0-9]{1}-[0-9]{3}-[0-9]{3}-[0-9]{4})|([0-9]{3}-[0-9]{3}-[0-9]{4})|([0-9]{3}-[0-9]{4})", "string",
                "Phone Number - regular expression that can be used to validate format of user input", true, false);
        this.createAndInsertSystemConstant(context, "allow.multiple.companies", "true", "boolean",
                "Company - allow tracking of multiple companies/divisions in software", true, false);
        this.createAndInsertSystemConstant(context, "users.can.view.other.companies", "true", "boolean",
                "Users can view companies not assigned to", true, false);
        this.createAndInsertSystemConstant(context, "debug.display", "false", "boolean",
                "Debug - display debug info on GUI forms", false, true);
        this.createAndInsertSystemConstant(context, "debug.simulate.email", "true", "boolean",
                "Debug - don\'t send e-mails, just show emails in log", false, true);
        this.createAndInsertSystemConstant(context, "mail.host", "hxmx06.hexacta.com", "string", "Mail Host", true,
                false);
        this.createAndInsertSystemConstant(context, "mail.user", "recruit@hexacta.com", "string", "Mail User", true,
                false);
        this.createAndInsertSystemConstant(context, "mail.password", "reit08", "string", "Mail Password", true, false);
        this.createAndInsertSystemConstant(context, "mail.from.name", "FlashRecruitAdmin", "string",
                "FlashRecruit Mailer", true, false);
        this.createAndInsertSystemConstant(context, "mail.from.address", "recruit@hexacta.com", "string",
                "Mail From Address", true, false);
        this.createAndInsertSystemConstant(context, "public.site.context", "http://localhost:80/recruit", "string",
                "Public Site - IP Address Context", true, false);
        this.createAndInsertSystemConstant(context, "public.site.show.application", "true", "boolean",
                "Public Site - Allow candidates to submit job applications", true, false);
        this.createAndInsertSystemConstant(context, "job.posting.require.ref.id", "true", "boolean",
                "Job - require reference id to be generated or entered", true, false);
        this.createAndInsertSystemConstant(context, "job.auto.ref.id", "true", "boolean",
                "Job - automatically generate reference id for new job.", true, false);
        this.createAndInsertSystemConstant(context, "job.auto.ref.id.prefix", "J", "string",
                "Job - reference id prefix - used only if auto generated", true, false);
        this.createAndInsertSystemConstant(context, "job.posting.recruiting.firm", "true", "boolean",
                "Job - recruiting firm style and functionality for posting jobs", true, false);
        this.createAndInsertSystemConstant(context, "job.posting.public.show.company", "true", "boolean",
                "Job - show company on postings", true, false);
        this.createAndInsertSystemConstant(context, "job.posting.edit.company.select", "true", "boolean",
                "Job - select company on edit form", true, false);
        this.createAndInsertSystemConstant(context, "job.posting.list.show.company.ref.id", "true", "boolean",
                "Job - show company reference id on job list", true, false);
        this.createAndInsertSystemConstant(context, "job.posting.list.show.ref.code", "true", "boolean",
                "Job - show job reference id on job list", true, false);
        this.createAndInsertSystemConstant(context, "pub.job.list.show.company", "false", "boolean",
                "Job - show company on public job list", true, false);
        this.createAndInsertSystemConstant(context, "job.posting.list.show.icon", "false", "boolean",
                "Job - show icon for job list", true, false);
        this.createAndInsertSystemConstant(context, "job.posting.compact.list.show.company.ref.id", "false", "boolean",
                "Job - show company ref id on compact job lists", true, false);
        this.createAndInsertSystemConstant(context, "job.posting.compact.list.show.ref.id", "false", "boolean",
                "Job - show job ref id on compact job lists", true, false);
        this.createAndInsertSystemConstant(context, "job.posting.list.show.company.name", "false", "boolean",
                "Job - show company name on job lists", true, false);
        this.createAndInsertSystemConstant(context, "job.posting.compact.list.show.icon", "false", "boolean",
                "Job - show status icon on compact job lists", true, false);
        this.createAndInsertSystemConstant(context, "recruit.mgr.has.all.as.my.jobs", "false", "boolean",
                "Recruit Mgr sees all jobs on \"My Job List\"", true, false);
        this.createAndInsertSystemConstant(context, "resume.index.batch.interval", "60", "long",
                "Resume - how often indexing should this be donecreateAndInsertSystemConstant(context,seconds)", true,
                false);
        this
                .createAndInsertSystemConstant(
                        context,
                        "resume.expire.days",
                        "180",
                        "long",
                        "Resume - number of days for a resume to expirecreateAndInsertSystemConstant(context,not be scanned anymore)",
                        true, false);
        this.createAndInsertSystemConstant(context, "resume.scan.min.count", "200", "long",
                "Resume - default minimum count for resume scans", true, false);
        this.createAndInsertSystemConstant(context, "resume.scan.max.count", "200", "long",
                "Resume - default maximum count for resume scans", true, false);
        this.createAndInsertSystemConstant(context, "resume.scan.min.percent.cutoff", "60", "long",
                "Resume - min score drop off before resumes with lower score are excluded", true, false);
        this.createAndInsertSystemConstant(context, "email.resume.batch.startup.seconds", "120", "long",
                "Number of seconds to wait until running emailed resume batch for first time", false, true);
        this.createAndInsertSystemConstant(context, "email.resume.batch.interval", "120", "long",
                "Number of seconds between email resume batch runs", false, true);
        this.createAndInsertSystemConstant(context, "resume.recipient.email.store.type", "pop3", "string",
                "Resume - type of store for emailed resume inbox, pop3 or imap", true, false);
        this.createAndInsertSystemConstant(context, "resume.recipient.email.addr", "recruit@hexacta.com", "string",
                "Resume - address for email account that receives resumes", true, false);
        this.createAndInsertSystemConstant(context, "resume.recipient.email.password", "reit08", "string",
                "Resume - password for email account that receives resumes", true, false);
        this.createAndInsertSystemConstant(context, "resume.recipient.email.host", "pop3.hexacta.com", "string",
                "Resume - host that holds emailed resumes", true, false);
        this.createAndInsertSystemConstant(context, "report.show.vectrics.logo", "false", "boolean",
                "Show Vectrics Logo on Reports", true, false);
        this.createAndInsertSystemConstant(context, "security.pwd.email.candidate", "true", "boolean",
                "Security - allow emailing of candidate password", true, false);
        this.createAndInsertSystemConstant(context, "security.candidate.user.is.pwd", "true", "boolean",
                "Security - candidate user name is candidate e-mail address", true, false);
        this.createAndInsertSystemConstant(context, "security.pwd.email.rqr.quest", "true", "boolean",
                "Security - candidate can be e-mailed only after answer question", true, false);
        this.createAndInsertSystemConstant(context, "email.primary.unique", "true", "boolean",
                "Each user\'s primary email must be unique", true, false);
        this
                .createAndInsertSystemConstant(
                        context,
                        "security.enforce.company.scope",
                        "true",
                        "boolean",
                        "Make sure users are associated with company for changes to company datacreateAndInsertSystemConstant(context,including jobs)",
                        true, false);
        this.createAndInsertSystemConstant(context, "password.encrypt.key", "kaA3sfa3", "string",
                "Password encryption key - arbitrary but must be 8 characters", false, true);
        this.createAndInsertSystemConstant(context, "workflow.db.jndi", "java:/VectricsWokflowDb", "string",
                "Worflow Data Source JNDI", false, true);
        this.createAndInsertSystemConstant(context, "module.public.application", "true", "boolean",
                "Module - allow users to apply to jobs on public site", true, false);
        this.createAndInsertSystemConstant(context, "module.job.agent", "true", "boolean",
                "Module - allow users to create job agents", true, false);
        this.createAndInsertSystemConstant(context, "module.public.resume", "true", "boolean",
                "Module - allow users to submit resumes", true, false);
        this.createAndInsertSystemConstant(context, "module.task", "false", "boolean",
                "Module - allow tasks to be assigned to users", false, true);
        this.createAndInsertSystemConstant(context, "module.hosting", "false", "boolean",
                "Module - functionality for FlashRecruit hostingcreateAndInsertSystemConstant(context,proprietary)",
                false, true);
        this.createAndInsertSystemConstant(context, "module.public.site.candidate", "true", "boolean",
                "Module - candidate can register, maintain profile, etc", true, false);
        this.createAndInsertSystemConstant(context, "module.candidate.apply", "true", "boolean",
                "Module - candidate can apply for jobs on public site", true, false);
        this.createAndInsertSystemConstant(context, "person.system.person.id", "1", "long", "System User", false, true);
        this.createAndInsertSystemConstant(context, "person.batch.person.id", "1", "long", "Batch User", false, true);
        this.createAndInsertSystemConstant(context, "person.test.person.id", "1", "long", "Test User", false, true);
        this.createAndInsertSystemConstant(context, "person.email.required.for.admin", "true", "boolean",
                "Require email for person edit in admin site", true, false);
        this.createAndInsertSystemConstant(context, "job.agent.batch.startup.seconds", "300", "long",
                "Number of seconds to wait until running emailed resume batch for first time", false, true);
        this.createAndInsertSystemConstant(context, "job.agent.batch.interval", "300", "long",
                "Number of seconds between job agent batch runs", false, true);
        this.createAndInsertSystemConstant(context, "document.index.batch.startup.seconds", "120", "long",
                "Number of seconds to wait until document indexing batch for first time", false, true);
        this.createAndInsertSystemConstant(context, "document.index.batch.interval", "30", "long",
                "Number of seconds between document indexing batch runs", false, true);
        this.createAndInsertSystemConstant(context, "resume.expire.batch.startup.seconds", "200", "long",
                "Number of seconds to wait until running resume expire batch for first time", false, true);
        this.createAndInsertSystemConstant(context, "resume.expire.batch.interval", "6000", "long",
                "Number of seconds between resume expire batch runs", false, true);
        this.createAndInsertSystemConstant(context, "event.error.retry", "3", "long",
                "Events - number of retries for events that fail processing", true, false);
        this.createAndInsertSystemConstant(context, "event.proc.batch.interval", "30", "long",
                "Events - interval between batch runs, in seconds.", false, true);
        this.createAndInsertSystemConstant(context, "event.proc.startup.seconds", "120", "long",
                "Number of seconds to wait until running event processor for first time", false, true);
        this.createAndInsertSystemConstant(context, "emailed.resumes.batch.startup.seconds", "120", "long",
                "Number of seconds to wait until running emailed resume batch for first time", false, true);
        this.createAndInsertSystemConstant(context, "emailed.resumes.batch.interval.seconds", "120", "long",
                "Number of seconds to wait until running emailed resume batch for first time", false, true);
        this.createAndInsertSystemConstant(context, "calendar.module.enabled", "true", "boolean",
                "Calendar functionality enabled", false, true);
        this.createAndInsertSystemConstant(context, "job.default.location", "4000000005", "long",
                "Default location for new jobs", true, false);
        this.createAndInsertSystemConstant(context, "data.host", "http://localhost:8100/hrs-intranet", "string",
                "Host where the application is running", false, true);
        this.createAndInsertSystemConstant(context, "data.directory", "/data/hexacta", "string",
                "Directory where Vectrics applications will store documents and cached information", false, true);
        this.createAndInsertSystemConstant(context, "debug.javascript", "false", "long",
                "Show debug information for JavaScript methods - usually false", false, true);
        this.createAndInsertSystemConstant(context, "system.version", Version.SCHEMA_VERSION, "string",
                "Application Version", true, true);
    }

    private void createAndInsertSystemConstant(Map<String, Object> context, String code, String value, String type,
            String description, boolean canPassToChildren, boolean global) {
        SystemConstant constant = this.createSystemConstant(context, code, value, type, description, canPassToChildren,
                global);
        this.insertDomainObject(constant);
    }

    private SystemConstant createSystemConstant(Map<String, Object> context, String code, String value, String type,
            String description, boolean canPassToChildren, boolean global) {
        Domain hexactaDomain = this.loadObjectFromContext(context, DomainTestDataDependencyCreator.HEXACTA_DOMAIN);
        SystemConstant constant = new SystemConstant();
        constant.setCode(code);
        constant.setDomain(hexactaDomain);
        constant.setValue(value);
        constant.setType(type);
        constant.setDescription(description);
        constant.setCanPassToChildren(canPassToChildren);
        constant.setGlobal(global);
        return constant;
    }

}
